import QtQuick 2.12
import QtQuick.Controls 2.12
import ".."

Rectangle
{
    id: myButton
    implicitHeight: 40
    implicitWidth: 100
    property alias text: btnText.text
    property alias size: btnText.font.pixelSize
    property bool hovered: false
    signal clicked()
    scale: clickArea.pressed ? 0.95 : 1
    color: enabled  ? (hovered ? "#0589D4" : Common.colorMain) : Common.colorInvalid
    border.color: enabled ? Common.colorMain : "#EEEEEE"
    border.width: 1
    radius: 4

    Text {
        id: btnText
        font.family: Common.fontMain
        font.pixelSize: 14
        anchors.centerIn: parent
        horizontalAlignment: Label.AlignHCenter
        verticalAlignment: Label.AlignVCenter
        width: parent.width - 10
        elide: Text.ElideRight
        color: "white"
    }

    MouseArea {
        id: clickArea
        hoverEnabled: true
        onEntered: myButton.hovered = true
        onExited: myButton.hovered = false
        anchors.fill: parent
        onClicked: {
            myButton.clicked()
        }
    }
}
